<template>
  <div id="app">
    <div id="nav">
      <router-link to="/">主页</router-link>|
      <router-link to="/about">关于</router-link>|
      <router-link to="/example">测试</router-link>|
      <router-link v-if="!isLogin" to="/login">用户登录</router-link>
      <router-link v-else to="/userInfo">用户信息</router-link>
      | <router-link to="/score">成绩计算</router-link>
    </div>
    <router-view v-on:loginSuccess="setLogin" v-on:quitlogin="quitOperation" />
  </div>
</template>

<script>
export default {
  created() {},
  data() {
    return {
      isLogin: false
    };
  },
  methods: {
    setLogin(flag) {
      this.isLogin = flag;
      this.$router.push("UserInfo");    //编程式路由
    },
    quitOperation() {
      this.isLogin = false;
      this.$router.push("Login");
    }
  }
};
</script>

<style lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
